package com.example.presentshopping.ui.activity

import android.annotation.SuppressLint
import android.os.Bundle
import com.example.presentshopping.R
import com.example.presentshopping.config.base.BaseMvpActivity
import com.tencent.smtt.sdk.WebChromeClient
import com.tencent.smtt.sdk.WebSettings
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_turntable.*

class TurntableActivity : BaseMvpActivity() {

    var url :String ?=null
    var ableActivity :String ?= null
    var title :String ?= null

    override val layoutId: Int
        get() = R.layout.activity_turntable





    override fun initView(savedInstanceState: Bundle?) {
        title_main_tv.leftBackImageTv.setOnClickListener { finish() }

        val webSettings: WebSettings = webfilechooser.settings
        webSettings.javaScriptEnabled = true
        // 设置允许JS弹窗
        webSettings.javaScriptCanOpenWindowsAutomatically = true

        ableActivity =intent.getStringExtra("Activity")
        url =intent.getStringExtra("url")
        title =intent.getStringExtra("title")

        webfilechooser.webChromeClient = WebChromeClient()
        if (ableActivity?.contains("Turntable")!!){
            webfilechooser?.loadUrl("file:///android_asset/game.html")
        }else{
            title_main_tv.titleTv.text = title
            webfilechooser?.loadUrl(url)
        }



    }

    override fun showToast(msg: String?) {

    }

    override fun onSuccess(data: String?) {

    }

    override fun onFailure(e: Throwable?, code: Int, msg: String?, isNetWorkError: Boolean) {

    }


    /**
     * 确保注销配置能够被释放
     */


}